import { lazy } from "react";
import { useRoutes } from "react-router-dom";

const Home = lazy(() => import("@/views/home/Home"));
const Users = lazy(() => import("@/views/users/UsersIndex"));
const Goods = lazy(() => import("@/views/goods/GoodsIndex"));

interface Router {
  name?: string;
  path: string;
  children?: Array<Router>;
  element: any;
}

const routers: Array<Router> = [
  {
    path: `/home`,
    name: "home",
    element: <Home />,
  },
  {
    path: `/usersIndex`,
    name: "usersIndex",
    element: <Users />,
  },
  {
    path: `/goodsIndex`,
    name: "goodsIndex",
    element: <Goods />,
  },
];

const AppRouters = () => useRoutes(routers);

export default AppRouters;
